<template>
    <bi-form ref="form">
        <bi-card >
            <bi-form-item label="运费">
                <bi-input type="int" v-model="form.money" required>
                    <template #after>元</template>
                </bi-input>
            </bi-form-item>

            <bi-form-item label="免运费金额">
                <bi-input type="int" v-model="form.free" required >
                    <template #after>元</template>
                </bi-input>
            </bi-form-item>
            <bi-form-item label="运费说明">
                <bi-input v-model="form.desc"  />
            </bi-form-item>
            <template #footer>
                <bi-button type="primary" @click="update">保存</bi-button>
            </template>
        </bi-card>
    </bi-form>
</template>

<script>
export default {
    data(){
        let form ={
            money:0,
            free:0,
            desc:''
        }
        this.$assign(form,this.$pageData.freight)
        return {
            form
        }
    },
    methods:{
        update(){
            if (this.$refs.form.check()){
                this.$ajax({
                    url:this.$url({action:'saveFreight'}),
                    data:{
                        ...this.form
                    },
                    success:()=>{
                        this.$toast('保存成功');
                    }
                })
            }
        }
    }
}
</script>

